home *** CD-ROM | disk | FTP | other *** search
- { SPX Library Version 3.0 Copyright 1993 Scott D. Ramsay }
-
- SPX_GEO is the geomorph "tile map" handling unit. It allows you to
- scroll large maps. The maps are composed of sprites that are aligned
- next to each other like a tile floor.
-
- ───────────────────────────────────────────────────────────────────────────
- type
- Pmorph = ^Tmorph;
- Tmorph = object
-
-
- VARIABLES:
- gosx,gofsy:byte: Used internally. Indicates the pixel offset of
- the map;
- gv_width: Width of sprites to display. (in tiles amount);
- gv_height: Height of sprites to display. (in tiles);
- gmx,gmy: Width and height of geomorph (in tiles);
- gsx,gsy: Width and height of tile (in pixels);
- hvx,hvy: Used internally; = gv_width div 2,gv_height div 2;
- smapx,smapy: Top-left corner region of geomorph;
- yaccum,xaccum: Used internally; accumlators to draw the tiles
- yinc,xinc: Used internally; addition accumlators
-
- ---------------------------------------------------
- constructor Tmorph.init(geomx,geomy,six,siy,gvw,gvh,scrx,scry:integer);
- Sets up the object.
-
- GEOMX: Width of geomorph (in tiles);
- GEOMY: Height of geomorph (in tiles);
- SIX: Width of the tiles
- SIY: Height of the tiles
- GVW: Width of tiles to display (in tiles);
- GVH: Height of tiles to display (in tiles);
- SCRX,SCRY: Top-left corner region of geommorph
-
- ---------------------------------------------------
- destructor Tmorph.done; virtual;
-
- Deallocates the object
-
- ---------------------------------------------------
- procedure Tmorph.yaccumulator(inital:boolean;at:integer);virtual;
-
- Used in the drawing loop to increment in the y position
-
- OVERRIDE: Seldom
-
- ---------------------------------------------------
- procedure Tmorph.xaccumulator(inital:boolean;at:integer);virtual;
-
- Used in the drawing loop to increment in the x position
-
- OVERRIDE: Seldom
-
- ---------------------------------------------------
- function Tmorph.geomap(x,y:integer):integer;virtual;
-
- Returns the tile number at the (X,Y) coordinate.
-
- X,Y: Tile positon of geomorph (in tiles)
-
- OVERRIDE: Always
-
- ---------------------------------------------------
- procedure Tmorph.drawmap(vx,vy:integer);virtual;
-
- Displays the geomorph on the active page.
-
- VX,VY: Center position area of geomorph to display.
- (in pixels)
-
- VX is usually in the range 0..geomorph_width*sprite_width-1
- VY is usually in the range 0..geomorph_height*sprite_height-1
-
- ---------------------------------------------------
- procedure Tmorph.placegeo(x,y,geonum,cx,cy:integer);virtual;
-
- Called from Tmorph.drawmap. Displays a tile on the screen.
-
- X,Y: Top-left position of tile to display;
- GEONUM: Tile number to display
- CX,CY: width, height counter position of tile
-
- OVERRIDE: Often
-
- Usually your override procedure would look something like:
-
- procedure TMyMorph.placegeo(x,y,geonum,cx,cy:integer);
- begin
- fput(x,y,geo_tiles[geonum]^);
- end;
-
- ---------------------------------------------------
- procedure Tmorph.nogogeo(x,y,cx,cy:integer);virtual;
-
- Called from Tmorph.drawmap. Is called when a tile is
- out of map range.
-
- ---------------------------------------------------
- procedure Tmorph.pre_map; virtual;
-
- Called before each drawing of the geomorph.
-
- ---------------------------------------------------
- procedure Tmorph.post_map; virtual;
-
- Called after each drawing of the geomorph.
-
- ───────────────────────────────────────────────────────────────────────────
-
- type
- PHexMorph = ^THexMorph;
- THexMorph = object(Tmorph)
-
- This desendant of Tmorph allows for irregular spacing of the tile map.
-
- VARIABLES:
- oddy,oddx: Sets the (x,y) offset position of the odd columns
- evenx,eveny: Sets the (x,y) offset position of the even columns
-
- By default the above variables are set to zero. (will function like
- a Tmorph object)
-
-
- ───────────────────────────────────────────────────────────────────────────
- function loadGMP(f:string;var piclist,map):integer;
-
- Load a .GMP file from disk.
-
- F: DOS file name of GMP file to load;
- PICLIST: Array of pointer to hold the tiles;
- MAP: Array of byte or word to hold the map
-
- Returns the number of tiles in the GMP file.
-
- The example below loads a 100,100 GMP file:
-
- const
- gmx = 100;
- gmy = 100;
-
- var
- geo_tiles : array[1..100] of pointer;
- MyMap : array[0..gmy-1,0..gmx-1] of byte;
- geos : integer;
-
- begin
- geos := LoadGMP('MyGMP.GMP',geo_tiles,MyMap);
- end;
- ───────────────────────────────────────────────────────────────────────────
- function loadGMPLib(lib:pSpxLib;f:string;var piclist,map):integer;
-
- Same as loadGMP, loads a GMP file from a SPX library file
- ───────────────────────────────────────────────────────────────────────────